package hash;

// 242
public class Solution {
    public static void main(String[] args) {
        System.out.print(new Solution().isAnagram(new String("abc"), new String("abc")));
    }
    public boolean isAnagram(String s, String t) {
        if (s.length() != t.length()) return false;
        int[] arr = new int[40];
        for (int i = 0; i < s.length(); i++) {
            int index = s.charAt(i) - 'a';
            arr[index] ++;
        }
        for (int i = 0; i < t.length(); i++) {
            int index = t.charAt(i) - 'a';
            arr[index] --;
            if (arr[index] < 0) {
                return false;
            }
        }
        return true;
    }
}
